//
//  MydetailedController.m
//  Ten
//
//  Created by anfuer on 2018/8/16.
//  Copyright © 2018年 xg韦. All rights reserved.
//

#import "MydetailedController.h"
#import "MyDetailedCell.h"
#import "HomeTbvCell.h"
@interface MydetailedController ()
{
    NSDictionary*dataDic;
}
@property (weak, nonatomic) IBOutlet UITableView *tbv;
@property (weak, nonatomic) IBOutlet WxgButton *hidenBtno;

@end

@implementation MydetailedController

- (void)viewDidLoad {
    [super viewDidLoad];
    _tbv.separatorColor=[UIColor clearColor];
    UIView *v = [[UIView alloc] initWithFrame:CGRectZero];
    [_tbv setTableFooterView:v];
    [self loadata];

    
    // Do any additional setup after loading the view.
}
-(void)loadata
{
    [FuncPublic getData:self parameters:@{@"id":_cid} RequestUrl:Cdelivers_detail success:^(NSDictionary *acountInfo) {
        dataDic=acountInfo[@"data"];
        [_tbv reloadData];
        if ([WXGStr(dataDic[@"status"])isEqualToString:@"0"]&&[WXGStr(dataDic[@"type"])isEqualToString:@"2"]) {
            _hidenBtno.hidden=NO;
        }else
        {
            _hidenBtno.hidden=YES;
        }
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)btna:(UIButton *)sender {
    if ([[sender currentTitle]containsString:@"任务"]) {
        [FuncPublic getData:nil parameters:@{@"id":_cid} RequestUrl:accept_deliver success:^(NSDictionary *acountInfo) {
            [WSProgressHUD showImage:nil status:@"请求成功"];
            [self loadata];
            
        }];
    }else
    {
        NSMutableString* str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",dataDic[@"company"][@"phone"]];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    }
    
}

#pragma mark 返回分组数
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

#pragma mark 返回每组行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    if (indexPath.section==0) {
        HomeTbvCell*cell=[HomeTbvCell CellWithTableView:tableView];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (dataDic) {
            NSMutableDictionary*mdic=[NSMutableDictionary dictionaryWithDictionary:dataDic[@"job_detail"]];
            [mdic setObject:dataDic[@"company"] forKey:@"company"];
            [cell Cellinit:mdic];
        }
        
        return cell;
    }else
    {
        MyDetailedCell*cell=[MyDetailedCell CellWithTableView:tableView];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.lb1.text=dataDic[@"status_name"];
        
        NSMutableString*mstr=[NSMutableString string];
        if (![WXGStr(dataDic[@"add_time"]) empty]) {
              [mstr appendFormat:@"投递时间:%@\n\n",dataDic[@"add_time"]];
        }
        if (![WXGStr(dataDic[@"see_time"]) empty]) {
             [mstr appendFormat:@"被查看时间:%@\n\n",dataDic[@"see_time"]];
        }
        if (![WXGStr(dataDic[@"face_time"]) empty]) {
             [mstr appendFormat:@"面试时间:%@\n\n",dataDic[@"face_time"]];
        }
        if (![WXGStr(dataDic[@"employ_time"]) empty]) {
             [mstr appendFormat:@"录用时间:%@\n\n",dataDic[@"employ_time"]];
        }
        if (![WXGStr(dataDic[@"complate_time"]) empty]) {
             [mstr appendFormat:@"工作结束时间:%@\n\n",dataDic[@"complate_time"]];
        }

        cell.lb2.text=mstr;
        
        return cell;
    }
 
}
#pragma mark 设置分组头高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return section==0?0:10;
}


#pragma mark 设置尾部说明内容高度
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}

#pragma mark 设置每行高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  
    return indexPath.section==0?[HomeTbvCell FSCellHeightForTableView:tableView indexPath:indexPath cacheKey:@"HomeTbvCell" cellContentViewWidth:0 bottomOffset:0]:[MyDetailedCell FSCellHeightForTableView:tableView indexPath:indexPath cacheKey:@"MyDetailedCell" cellContentViewWidth:0 bottomOffset:30];
    
}
#pragma mark 点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{
    
}



@end
